package com.tz.yiqingapp.controller.common;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tz.yiqingapp.bean.DiabetesBean;
import com.tz.yiqingapp.bean.Spiderlog;
import com.tz.yiqingapp.dto.PageDTO;
import com.tz.yiqingapp.mapper.SpiderMapper;
import com.tz.yiqingapp.services.dao.CommandServiceImpl;
import com.tz.yiqingapp.utils.ResponseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.jaxb.SpringDataJaxb;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

@RestController
@RequestMapping("/spider")
public class SpiderController {


    @Autowired
    CommandServiceImpl commandService;

    @Autowired
    SpiderMapper spiderMapper;

    @PostMapping("/getlast")
    public HashMap<String,Object> getlast (@RequestBody DiabetesBean diabetesBean, HttpServletRequest request){

        QueryWrapper<Spiderlog> spiderlogQueryWrapper = new QueryWrapper<>();
        spiderlogQueryWrapper.orderByDesc("id");
        var spiderlog = spiderMapper.selectList(spiderlogQueryWrapper);
        if(spiderlog.size()>0) {
            return ResponseUtils.success(spiderlog.get(0));
        }
        return ResponseUtils.fail("not spider log");
    }


}
